package com.ruoyi.framework.security;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 注册服务
 *
 * @author ruoyi
 */
@Service
public class SysRegisterService
{
    @Autowired
    private ISysUserService userService;

    /**
     * 注册用户
     */
    public String register(SysUser user)
    {
        try
        {
            // 加密密码
            user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
            // 保存用户
            int result = userService.insertUser(user);
            return result > 0 ? null : "注册失败";
        }
        catch (Exception e)
        {
            return e.getMessage();
        }
    }
}

